home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / etc_-_Configuration_Files / RC.D / RC.6 < prev   
Text File  |  1999-09-17  |  3KB  |  119 lines

  1. #! /bin/sh
  2. #
  3. # rc.6        This file is executed by init when it goes into runlevel
  4. #        0 (halt) or runlevel 6 (reboot). It kills all processes,
  5. #        unmounts file systems and then either halts or reboots.
  6. #
  7. # Version:    @(#)/etc/rc.d/rc.6    1.50    1994-01-15
  8. #
  9. # Author:    Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
  10. # Modified by:  Patrick J. Volkerding, <volkerdi@ftp.cdrom.com>
  11. #
  12.  
  13.   # Set the path.
  14.   PATH=/sbin:/etc:/bin:/usr/bin
  15.  
  16.   # Set linefeed mode to avoid staircase effect.
  17.   stty onlcr
  18.  
  19.   echo "Running shutdown script $0:"
  20.  
  21.   # Find out how we were called.
  22.   case "$0" in
  23.     *0)
  24.         command="halt"
  25.         ;;
  26.     *6)
  27.         command=reboot
  28.         ;;
  29.     *)
  30.         echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
  31.         exit 1
  32.         ;;
  33.   esac
  34.  
  35.   # Kill all processes.
  36.   # INIT is supposed to handle this entirely now, but this didn't always
  37.   # work correctly without this second pass at killing off the processes.
  38.   # Since INIT already notified the user that processes were being killed,
  39.   # we'll avoid echoing this info this time around.
  40.   if [ "$1" != "fast" ]; then # shutdown did not already kill all processes
  41.     killall5 -15 
  42.     sleep 5
  43.     killall5 -9
  44.   fi
  45.  
  46.   # Try to turn off quota and accounting.
  47.   if [ -x /usr/sbin/quotaoff ]
  48.   then
  49.     echo "Turning off quota."
  50.     /usr/sbin/quotaoff -a
  51.   fi
  52.   if [ -x /sbin/accton ]
  53.   then
  54.     echo "Turning off accounting."
  55.     /sbin/accton
  56.   fi
  57.  
  58.   # Before unmounting file systems write a reboot or halt record to wtmp.
  59.   $command -w
  60.  
  61.   # Unmount any remote filesystems:
  62.   echo "Unmounting remote filesystems."
  63.   umount -a -tnfs
  64.  
  65.   ## WinLinux must check if this was a cold boot and reset autoexec and
  66.   ## config files in that case
  67.   CONFIG="/DOS/config.sys"
  68.   CONFIGWOS="/DOS/config.wos"
  69.   AEXEC="/DOS/autoexec.bat"
  70.   AEXECWOS="/DOS/autoexec.wos"
  71.   KEYWORD="DOS"
  72.   PAR="SINGLE"
  73.   TEMPFILE="/tmp/autoexec.bat.$$"
  74.   if [ -e "$CONFIG" ] ; then
  75.     if grep -i $KEYWORD $CONFIG | grep -i $PAR > /dev/null ; then
  76.       if [ -e $CONFIGWOS -a -e $AEXECWOS ] ; then
  77.         grep -vi 'LINUX.BAT' $AEXEC > $TEMPFILE
  78.         rm -f $AEXEC
  79.         cp $TEMPFILE $AEXEC > /dev/null 2>&1
  80.         rm -f $TEMPFILE
  81.       fi
  82.     fi
  83.   fi
  84.  
  85.   # Turn off swap, then unmount local file systems.
  86.   echo "Turning off swap."
  87.   swapoff -a
  88.   echo "Unmounting local file systems."
  89.   # Don't remount UMSDOS root volumes:
  90.   if [ ! "`mount | head -1 | cut -d ' ' -f 5`" = "umsdos" ]; then
  91.     umount -a -tnonfs
  92.     echo "Remounting root filesystem read-only."
  93.     mount -n -o remount,ro /
  94.   else
  95.     umount -a -tnonfs -tnoumsdos
  96.     touch /clean
  97.   fi
  98.   # This never hurts:
  99.   sync
  100.  
  101.   # See if this is a powerfail situation.
  102.   if [ -f /etc/power_is_failing ]; then
  103.     echo "Turning off UPS, bye."
  104.     /sbin/powerd -q
  105.     exit 1
  106.   fi
  107.  
  108.   # Now halt (poweroff with APM kernels) or reboot.
  109.   if [ "$command" = "reboot" ]; then
  110.     echo ""
  111.     echo "The system is being restarted..."
  112.     reboot -f
  113.   else
  114.     echo ""
  115.     echo "You can turn off your computer now."
  116.     halt -f -p
  117.   fi
  118.  
  119.